import { EdgeConfig, GraphModel, PolylineEdge, PolylineEdgeModel } from '@logicflow/core'
import { getBpmnId } from '../getBpmnId'

class SequenceFlowModel extends PolylineEdgeModel {
  static extendKey = 'SequenceFlowModel'
  constructor(data: EdgeConfig, graphModel: GraphModel) {
    if (!data.id) {
      data.id = `Flow_${getBpmnId()}`
    }
    super(data, graphModel)
  }
  getEdgeStyle() {
    const style = super.getEdgeStyle()
    const props = this.properties
    if (props.complete) {
      style.stroke = '#4097d7'
    } else {
      style.stroke = '#b1cbe4'
    }
    return style
  }
  getTextStyle() {
    const style = super.getTextStyle()
    style.color = '#666666'
    style.fontSize = 14
    return style
  }
}

class SequenceFlowView extends PolylineEdge {
  static extendKey = 'SequenceFlowEdge'
}

const SequenceFlow = {
  type: 'bpmn2:sequenceFlow',
  view: SequenceFlowView,
  model: SequenceFlowModel,
}

export { SequenceFlowView, SequenceFlowModel }
export default SequenceFlow
